using System;
using System.Collections.Generic;
using System.Text;
using MindFactorial.LaunchPoint.Common;

namespace MindFactorial.LaunchPoint.Runtime
{
    

    /// <summary>
    /// Lifetime Event Handler
    /// </summary>
    /// <param name="application">Application ID</param>  
    public delegate void LifetimeEventHandler(string application);

    /// <summary>
    /// Delegate handler for all Message broadcasting requests between runnable components and the LaunchPoint runtime
    /// </summary>
    /// <param name="application"></param>
    /// <param name="filter"></param>
    /// <param name="Message"></param>
    public delegate void BroadcastRequestHandler(string application, string filter, string Message);

    /// <summary>
    /// Delegate handler for all bre connection requests between runnable components and the LaunchPoint runtime
    /// </summary>
    /// <param name="transportTarget" />
    /// <param name="adapterID"></param>
    /// <param name="ruleID"></param>
    /// <param name="session_id"></param>
    /// <param name="arguments"></param>
    public delegate string BREConnectionRequestDelegate(Guid session_id,string transportTarget, string adapterID, string ruleID, string arguments);

    /// <summary>
    /// Delegate handler for all asynchronous bre connection requests between runnable components and the LaunchPoint runtime
    /// </summary>
    /// <param name="transportTarget" />
    /// <param name="adapterID"></param>
    /// <param name="ruleID"></param>
    /// <param name="arguments"></param>
    /// <param name="session_id"></param>
    /// <param name="callback"></param>
    public delegate void AsyncBREConnectionRequestDelegate(Guid session_id, string transportTarget, string adapterID, string ruleID, string arguments, AsyncRuleCompletedDelegate callback);

    /// <summary>
    /// Event to handle after the rule is executed
    /// </summary>
    /// <param name="cancelled">Cancelled or not</param>
    /// <param name="Code">Code</param>
    /// <param name="response">Response</param>
    /// <param name="ex">Exception</param>
    public delegate void RuleCompletedEventHandler(bool cancelled, int Code, Xml response, Exception ex);

    /// <summary>
    /// delegate for handling asynchronous requests to the rule engine
    /// </summary>
    /// <param name="response"></param>
    public delegate void AsyncRuleCompletedDelegate(string response);


    /// <summary>
    /// used to filter incomming Messages for the purpose of determining
    /// the appropriate Message to subscribe to
    /// </summary>
    /// <param name="header"></param>
    /// <returns></returns>
    public delegate bool IncommingMessageFiltrationHandler(string header);

    /// <summary>
    /// used to handle incomming Messages from beyond the runtime
    /// </summary>
    /// <param name="Message"></param>
    public delegate void IncommingMessageRequestHandler(string Message);

    /// <summary>
    /// marchals communication registration data between the LaunchPoint runtime and the runnable component it
    /// is hosting
    /// </summary>
    /// <param name="filter"></param>
    /// <param name="request_handler"></param>
    internal delegate void IncommingMessageDelegate(IncommingMessageFiltrationHandler filter, IncommingMessageRequestHandler request_handler);
}
